package com.vcredit.creditcat.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.vcredit.creditcat.model.ChannelStatisticsConfigExternal_AD;
import com.vcredit.creditcat.vo.BuiSelectVo;
import com.vcredit.creditcat.vo.ChannelStatisticsConfigExternalVo;
import com.vcredit.creditcat.service.ChannelStatisticsConfigExternalService;
import com.vcredit.creditcat.service.MerchantProductService;
import com.vcredit.creditcat.framework.pagination.Page;
 /*
  * @author zhangxingong
  * @version 1.0
  * @since 1.0
 */
@RestController
@RequestMapping("/channelStatisticsConfigExternal")
public class ChannelStatisticsConfigExternalController extends BaseController {
    
    @Autowired
    private ChannelStatisticsConfigExternalService channelStatisticsConfigExternalService;
    
    @Autowired
    private MerchantProductService merchantProductService;
  
    @RequestMapping(value = "/list")
    public ModelAndView  showPageChannelStatisticsConfigExternal(HttpServletRequest request) {
        return new ModelAndView("channelstatisticsconfigexternal/channelStatisticsConfigExternalList");
    }  
	
	@RequestMapping(value = "/listChannelStatisticsConfigExternal", method = RequestMethod.GET)
	public Page<ChannelStatisticsConfigExternal_AD> findByPageChannelStatisticsConfigExternal(HttpServletRequest request) {
      return channelStatisticsConfigExternalService.findByPage(makeDefaultCriteria(request));
	}
	
	@RequestMapping(value = "/saveChannelStatisticsConfigExternal", method = RequestMethod.POST)
	public String saveChannelStatisticsConfigExternal(@RequestBody ChannelStatisticsConfigExternalVo channelStatisticsConfigExternalVo,HttpServletRequest request) {
	    channelStatisticsConfigExternalService.save(channelStatisticsConfigExternalVo);
		return SUCCESS;
	}
	   
    @RequestMapping(value = "/updateChannelStatisticsConfigExternal", method = RequestMethod.PUT)
    public String updateChannelStatisticsConfigExternal(@RequestBody ChannelStatisticsConfigExternal_AD channelStatisticsConfigExternal,HttpServletRequest request) {
        channelStatisticsConfigExternalService.update(channelStatisticsConfigExternal);
        return SUCCESS;
    }
    
    @RequestMapping(value = "/removeChannelStatisticsConfigExternal", method = RequestMethod.DELETE)
    public String removeChannelStatisticsConfigExternal(@RequestParam("ids") String ids ,HttpServletRequest request) {
        channelStatisticsConfigExternalService.removeChannelStatisticsConfigExternal(ids);
        return SUCCESS;
    }	
    
    @RequestMapping(value = "/listAllProduct")
    public List<BuiSelectVo> listAllProduct(HttpServletRequest request) {
        return merchantProductService.listAllProduct();
    }
}
